package com.yysoft.core.web.controller;

import com.github.pagehelper.PageInfo;
import com.yysoft.core.model.SysUser;
import com.yysoft.core.service.IUserService;
import com.yysoft.core.utils.annotation.AuthUser;
import com.yysoft.core.web.BaseController;
import com.yysoft.core.web.model.AjaxResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/user")
@RestController
public class UserController extends BaseController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/getUserList")
    @AuthUser
    public AjaxResponse getUserList(String curPage, String pageCount, String userName) {
        AjaxResponse ajaxResponse = new AjaxResponse();
        PageInfo<SysUser> pageInfo = userService.getUserList(Integer.parseInt(curPage), Integer.parseInt(pageCount), userName);
        ajaxResponse.setData(pageInfo);
        return ajaxResponse;
    }

    @RequestMapping("/removeUsers")
    @AuthUser
    public AjaxResponse removeUsers(String userIds) throws Exception {
        userService.removeUsers(userIds);
        return new AjaxResponse();
    }

}
